﻿using Corina.Datamodel.Base;
using Corina.Datamodel.Interface;
using Corina.Enumerations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Corina.Datamodel.Entities
{
    [XmlTypeAttribute(Namespace = "http://tempuri.org/")]
    public class DeviceInfo : DatamodelEntity, IDevice
    {
        #region Fields
        private int _id;
        private string _deviceSn = string.Empty;
        private int _deviceKindId = 0;
        private double _ratePrice = 0;
        private DateTime? _manufactureDate;
        private int _dataTransferTypeId = 0;
        #endregion

        #region Properties
        public int Id
        {
            get { return _id; }
            set
            {
                _id = value;
                RaisePropertyChanged(() => Id);
            }
        }
        public string DeviceSn
        {
            get { return _deviceSn; }
            set
            {
                _deviceSn = value;
                RaisePropertyChanged(() => DeviceSn);
            }
        }
        public int DeviceKindId
        {
            get { return _deviceKindId; }
            set
            {
                _deviceKindId = value;
                RaisePropertyChanged(() => DeviceKindId);
            }
        }
        public double RatePrice
        {
            get { return _ratePrice; }
            set
            {
                _ratePrice = value;
                RaisePropertyChanged(() => RatePrice);
            }
        }

        public DateTime? ManufactureDate
        {
            get { return _manufactureDate; }
            set
            {
                _manufactureDate = value;
                RaisePropertyChanged(() => ManufactureDate);
            }
        }

        public int DataTransferTypeId
        {
            get { return _dataTransferTypeId; }
            set
            {
                _dataTransferTypeId = value;
                RaisePropertyChanged(() => DataTransferTypeId);
            }
        }
        #endregion

        protected override IEnumerable<DatabaseColumn> InitColumns()
        {
            yield return new DatabaseColumn("Id", true);
            yield return new DatabaseColumn("DeviceSn");
            yield return new DatabaseColumn("DeviceKindId", false, true);
            yield return new DatabaseColumn("RatePrice");
            yield return new DatabaseColumn("ManufactureDate");
            yield return new DatabaseColumn("DataTransferTypeId");
        }
    }
}